<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - Lua 5.1.5 - src/llex.c</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - llex.c</td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">Lua 5.1.5</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">256</td>
            <td class="headerCovTableEntry">269</td>
            <td class="headerCovTableEntryHi">95.2 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2019-06-13 19:44:15</td>
            <td></td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<span class="lineNum">       1 </span>            : /*
<span class="lineNum">       2 </span>            : ** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $
<span class="lineNum">       3 </span>            : ** Lexical Analyzer
<span class="lineNum">       4 </span>            : ** See Copyright Notice in lua.h
<span class="lineNum">       5 </span>            : */
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : 
<span class="lineNum">       8 </span>            : #include &lt;ctype.h&gt;
<span class="lineNum">       9 </span>            : #include &lt;locale.h&gt;
<span class="lineNum">      10 </span>            : #include &lt;string.h&gt;
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : #define llex_c
<span class="lineNum">      13 </span>            : #define LUA_CORE
<span class="lineNum">      14 </span>            : 
<span class="lineNum">      15 </span>            : #include &quot;lua.h&quot;
<span class="lineNum">      16 </span>            : 
<span class="lineNum">      17 </span>            : #include &quot;ldo.h&quot;
<span class="lineNum">      18 </span>            : #include &quot;llex.h&quot;
<span class="lineNum">      19 </span>            : #include &quot;lobject.h&quot;
<span class="lineNum">      20 </span>            : #include &quot;lparser.h&quot;
<span class="lineNum">      21 </span>            : #include &quot;lstate.h&quot;
<span class="lineNum">      22 </span>            : #include &quot;lstring.h&quot;
<span class="lineNum">      23 </span>            : #include &quot;ltable.h&quot;
<span class="lineNum">      24 </span>            : #include &quot;lzio.h&quot;
<span class="lineNum">      25 </span>            : 
<span class="lineNum">      26 </span>            : 
<span class="lineNum">      27 </span>            : 
<span class="lineNum">      28 </span>            : #define next(ls) (ls-&gt;current = zgetc(ls-&gt;z))
<span class="lineNum">      29 </span>            : 
<span class="lineNum">      30 </span>            : 
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            : 
<span class="lineNum">      33 </span>            : #define currIsNewline(ls)       (ls-&gt;current == '\n' || ls-&gt;current == '\r')
<span class="lineNum">      34 </span>            : 
<span class="lineNum">      35 </span>            : 
<span class="lineNum">      36 </span>            : /* ORDER RESERVED */
<span class="lineNum">      37 </span>            : const char *const luaX_tokens [] = {
<span class="lineNum">      38 </span>            :     &quot;and&quot;, &quot;break&quot;, &quot;do&quot;, &quot;else&quot;, &quot;elseif&quot;,
<span class="lineNum">      39 </span>            :     &quot;end&quot;, &quot;false&quot;, &quot;for&quot;, &quot;function&quot;, &quot;if&quot;,
<span class="lineNum">      40 </span>            :     &quot;in&quot;, &quot;local&quot;, &quot;nil&quot;, &quot;not&quot;, &quot;or&quot;, &quot;repeat&quot;,
<span class="lineNum">      41 </span>            :     &quot;return&quot;, &quot;then&quot;, &quot;true&quot;, &quot;until&quot;, &quot;while&quot;,
<span class="lineNum">      42 </span>            :     &quot;..&quot;, &quot;...&quot;, &quot;==&quot;, &quot;&gt;=&quot;, &quot;&lt;=&quot;, &quot;~=&quot;,
<span class="lineNum">      43 </span>            :     &quot;&lt;number&gt;&quot;, &quot;&lt;name&gt;&quot;, &quot;&lt;string&gt;&quot;, &quot;&lt;eof&gt;&quot;,
<span class="lineNum">      44 </span>            :     NULL
<span class="lineNum">      45 </span>            : };
<span class="lineNum">      46 </span>            : 
<span class="lineNum">      47 </span>            : 
<span class="lineNum">      48 </span>            : #define save_and_next(ls) (save(ls, ls-&gt;current), next(ls))
<span class="lineNum">      49 </span>            : 
<span class="lineNum">      50 </span>            : 
<span class="lineNum">      51 </span><span class="lineCov">     272087 : static void save (LexState *ls, int c) {</span>
<span class="lineNum">      52 </span><span class="lineCov">     272087 :   Mbuffer *b = ls-&gt;buff;</span>
<span class="lineNum">      53 </span><span class="lineCov">     272087 :   if (b-&gt;n + 1 &gt; b-&gt;buffsize) {</span>
<span class="lineNum">      54 </span>            :     size_t newsize;
<span class="lineNum">      55 </span><span class="lineCov">         57 :     if (b-&gt;buffsize &gt;= MAX_SIZET/2)</span>
<span class="lineNum">      56 </span><span class="lineNoCov">          0 :       luaX_lexerror(ls, &quot;lexical element too long&quot;, 0);</span>
<span class="lineNum">      57 </span><span class="lineCov">         57 :     newsize = b-&gt;buffsize * 2;</span>
<span class="lineNum">      58 </span><span class="lineCov">         57 :     luaZ_resizebuffer(ls-&gt;L, b, newsize);</span>
<span class="lineNum">      59 </span>            :   }
<span class="lineNum">      60 </span><span class="lineCov">     272087 :   b-&gt;buffer[b-&gt;n++] = cast(char, c);</span>
<span class="lineNum">      61 </span><span class="lineCov">     272087 : }</span>
<span class="lineNum">      62 </span>            : 
<span class="lineNum">      63 </span>            : 
<span class="lineNum">      64 </span><span class="lineCov">         99 : void luaX_init (lua_State *L) {</span>
<span class="lineNum">      65 </span>            :   int i;
<span class="lineNum">      66 </span><span class="lineCov">       2178 :   for (i=0; i&lt;NUM_RESERVED; i++) {</span>
<span class="lineNum">      67 </span><span class="lineCov">       2079 :     TString *ts = luaS_new(L, luaX_tokens[i]);</span>
<span class="lineNum">      68 </span><span class="lineCov">       2079 :     luaS_fix(ts);  /* reserved words are never collected */</span>
<span class="lineNum">      69 </span>            :     lua_assert(strlen(luaX_tokens[i])+1 &lt;= TOKEN_LEN);
<span class="lineNum">      70 </span><span class="lineCov">       2079 :     ts-&gt;tsv.reserved = cast_byte(i+1);  /* reserved word */</span>
<span class="lineNum">      71 </span>            :   }
<span class="lineNum">      72 </span><span class="lineCov">         99 : }</span>
<span class="lineNum">      73 </span>            : 
<span class="lineNum">      74 </span>            : 
<span class="lineNum">      75 </span>            : #define MAXSRC          80
<span class="lineNum">      76 </span>            : 
<span class="lineNum">      77 </span>            : 
<span class="lineNum">      78 </span><span class="lineCov">         42 : const char *luaX_token2str (LexState *ls, int token) {</span>
<span class="lineNum">      79 </span><span class="lineCov">         42 :   if (token &lt; FIRST_RESERVED) {</span>
<span class="lineNum">      80 </span>            :     lua_assert(token == cast(unsigned char, token));
<span class="lineNum">      81 </span><span class="lineCov">         30 :     return (iscntrl(token)) ? luaO_pushfstring(ls-&gt;L, &quot;char(%d)&quot;, token) :</span>
<span class="lineNum">      82 </span><span class="lineCov">         15 :                               luaO_pushfstring(ls-&gt;L, &quot;%c&quot;, token);</span>
<span class="lineNum">      83 </span>            :   }
<span class="lineNum">      84 </span>            :   else
<span class="lineNum">      85 </span><span class="lineCov">         27 :     return luaX_tokens[token-FIRST_RESERVED];</span>
<span class="lineNum">      86 </span>            : }
<span class="lineNum">      87 </span>            : 
<span class="lineNum">      88 </span>            : 
<span class="lineNum">      89 </span><span class="lineCov">         36 : static const char *txtToken (LexState *ls, int token) {</span>
<span class="lineNum">      90 </span><span class="lineCov">         36 :   switch (token) {</span>
<span class="lineNum">      91 </span><span class="lineCov">         10 :     case TK_NAME:</span>
<span class="lineNum">      92 </span>            :     case TK_STRING:
<span class="lineNum">      93 </span>            :     case TK_NUMBER:
<span class="lineNum">      94 </span><span class="lineCov">         10 :       save(ls, '\0');</span>
<span class="lineNum">      95 </span><span class="lineCov">         10 :       return luaZ_buffer(ls-&gt;buff);</span>
<span class="lineNum">      96 </span><span class="lineCov">         26 :     default:</span>
<span class="lineNum">      97 </span><span class="lineCov">         26 :       return luaX_token2str(ls, token);</span>
<span class="lineNum">      98 </span>            :   }
<span class="lineNum">      99 </span>            : }
<span class="lineNum">     100 </span>            : 
<span class="lineNum">     101 </span>            : 
<span class="lineNum">     102 </span><span class="lineCov">         36 : void luaX_lexerror (LexState *ls, const char *msg, int token) {</span>
<span class="lineNum">     103 </span>            :   char buff[MAXSRC];
<span class="lineNum">     104 </span><span class="lineCov">         36 :   luaO_chunkid(buff, getstr(ls-&gt;source), MAXSRC);</span>
<span class="lineNum">     105 </span><span class="lineCov">         36 :   msg = luaO_pushfstring(ls-&gt;L, &quot;%s:%d: %s&quot;, buff, ls-&gt;linenumber, msg);</span>
<span class="lineNum">     106 </span><span class="lineCov">         36 :   if (token)</span>
<span class="lineNum">     107 </span><span class="lineCov">         36 :     luaO_pushfstring(ls-&gt;L, &quot;%s near &quot; LUA_QS, msg, txtToken(ls, token));</span>
<span class="lineNum">     108 </span><span class="lineCov">         36 :   luaD_throw(ls-&gt;L, LUA_ERRSYNTAX);</span>
<span class="lineNum">     109 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     110 </span>            : 
<span class="lineNum">     111 </span>            : 
<span class="lineNum">     112 </span><span class="lineCov">         27 : void luaX_syntaxerror (LexState *ls, const char *msg) {</span>
<span class="lineNum">     113 </span><span class="lineCov">         27 :   luaX_lexerror(ls, msg, ls-&gt;t.token);</span>
<span class="lineNum">     114 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     115 </span>            : 
<span class="lineNum">     116 </span>            : 
<span class="lineNum">     117 </span><span class="lineCov">      46974 : TString *luaX_newstring (LexState *ls, const char *str, size_t l) {</span>
<span class="lineNum">     118 </span><span class="lineCov">      46974 :   lua_State *L = ls-&gt;L;</span>
<span class="lineNum">     119 </span><span class="lineCov">      46974 :   TString *ts = luaS_newlstr(L, str, l);</span>
<span class="lineNum">     120 </span><span class="lineCov">      46974 :   TValue *o = luaH_setstr(L, ls-&gt;fs-&gt;h, ts);  /* entry for `str' */</span>
<span class="lineNum">     121 </span><span class="lineCov">      46974 :   if (ttisnil(o)) {</span>
<span class="lineNum">     122 </span><span class="lineCov">      23854 :     setbvalue(o, 1);  /* make sure `str' will not be collected */</span>
<span class="lineNum">     123 </span><span class="lineCov">      23854 :     luaC_checkGC(L);</span>
<span class="lineNum">     124 </span>            :   }
<span class="lineNum">     125 </span><span class="lineCov">      46974 :   return ts;</span>
<span class="lineNum">     126 </span>            : }
<span class="lineNum">     127 </span>            : 
<span class="lineNum">     128 </span>            : 
<span class="lineNum">     129 </span><span class="lineCov">      22292 : static void inclinenumber (LexState *ls) {</span>
<span class="lineNum">     130 </span><span class="lineCov">      22292 :   int old = ls-&gt;current;</span>
<span class="lineNum">     131 </span>            :   lua_assert(currIsNewline(ls));
<span class="lineNum">     132 </span><span class="lineCov">      22292 :   next(ls);  /* skip `\n' or `\r' */</span>
<span class="lineNum">     133 </span><span class="lineCov">      22292 :   if (currIsNewline(ls) &amp;&amp; ls-&gt;current != old)</span>
<span class="lineNum">     134 </span><span class="lineNoCov">          0 :     next(ls);  /* skip `\n\r' or `\r\n' */</span>
<span class="lineNum">     135 </span><span class="lineCov">      22292 :   if (++ls-&gt;linenumber &gt;= MAX_INT)</span>
<span class="lineNum">     136 </span><span class="lineNoCov">          0 :     luaX_syntaxerror(ls, &quot;chunk has too many lines&quot;);</span>
<span class="lineNum">     137 </span><span class="lineCov">      22292 : }</span>
<span class="lineNum">     138 </span>            : 
<span class="lineNum">     139 </span>            : 
<span class="lineNum">     140 </span><span class="lineCov">        480 : void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {</span>
<span class="lineNum">     141 </span><span class="lineCov">        480 :   ls-&gt;decpoint = '.';</span>
<span class="lineNum">     142 </span><span class="lineCov">        480 :   ls-&gt;L = L;</span>
<span class="lineNum">     143 </span><span class="lineCov">        480 :   ls-&gt;lookahead.token = TK_EOS;  /* no look-ahead token */</span>
<span class="lineNum">     144 </span><span class="lineCov">        480 :   ls-&gt;z = z;</span>
<span class="lineNum">     145 </span><span class="lineCov">        480 :   ls-&gt;fs = NULL;</span>
<span class="lineNum">     146 </span><span class="lineCov">        480 :   ls-&gt;linenumber = 1;</span>
<span class="lineNum">     147 </span><span class="lineCov">        480 :   ls-&gt;lastline = 1;</span>
<span class="lineNum">     148 </span><span class="lineCov">        480 :   ls-&gt;source = source;</span>
<span class="lineNum">     149 </span><span class="lineCov">        480 :   luaZ_resizebuffer(ls-&gt;L, ls-&gt;buff, LUA_MINBUFFER);  /* initialize buffer */</span>
<span class="lineNum">     150 </span><span class="lineCov">        480 :   next(ls);  /* read first char */</span>
<span class="lineNum">     151 </span><span class="lineCov">        480 : }</span>
<span class="lineNum">     152 </span>            : 
<span class="lineNum">     153 </span>            : 
<span class="lineNum">     154 </span>            : 
<span class="lineNum">     155 </span>            : /*
<span class="lineNum">     156 </span>            : ** =======================================================
<span class="lineNum">     157 </span>            : ** LEXICAL ANALYZER
<span class="lineNum">     158 </span>            : ** =======================================================
<span class="lineNum">     159 </span>            : */
<span class="lineNum">     160 </span>            : 
<span class="lineNum">     161 </span>            : 
<span class="lineNum">     162 </span>            : 
<span class="lineNum">     163 </span><span class="lineCov">       8807 : static int check_next (LexState *ls, const char *set) {</span>
<span class="lineNum">     164 </span><span class="lineCov">       8807 :   if (!strchr(set, ls-&gt;current))</span>
<span class="lineNum">     165 </span><span class="lineCov">       6898 :     return 0;</span>
<span class="lineNum">     166 </span><span class="lineCov">       1909 :   save_and_next(ls);</span>
<span class="lineNum">     167 </span><span class="lineCov">       1909 :   return 1;</span>
<span class="lineNum">     168 </span>            : }
<span class="lineNum">     169 </span>            : 
<span class="lineNum">     170 </span>            : 
<span class="lineNum">     171 </span><span class="lineCov">       3080 : static void buffreplace (LexState *ls, char from, char to) {</span>
<span class="lineNum">     172 </span><span class="lineCov">       3080 :   size_t n = luaZ_bufflen(ls-&gt;buff);</span>
<span class="lineNum">     173 </span><span class="lineCov">       3080 :   char *p = luaZ_buffer(ls-&gt;buff);</span>
<span class="lineNum">     174 </span><span class="lineCov">      10612 :   while (n--)</span>
<span class="lineNum">     175 </span><span class="lineCov">       7532 :     if (p[n] == from) p[n] = to;</span>
<span class="lineNum">     176 </span><span class="lineCov">       3080 : }</span>
<span class="lineNum">     177 </span>            : 
<span class="lineNum">     178 </span>            : 
<span class="lineNum">     179 </span><span class="lineCov">          1 : static void trydecpoint (LexState *ls, SemInfo *seminfo) {</span>
<span class="lineNum">     180 </span>            :   /* format error: try to update decimal point separator */
<span class="lineNum">     181 </span><span class="lineCov">          1 :   struct lconv *cv = localeconv();</span>
<span class="lineNum">     182 </span><span class="lineCov">          1 :   char old = ls-&gt;decpoint;</span>
<span class="lineNum">     183 </span><span class="lineCov">          1 :   ls-&gt;decpoint = (cv ? cv-&gt;decimal_point[0] : '.');</span>
<span class="lineNum">     184 </span><span class="lineCov">          1 :   buffreplace(ls, old, ls-&gt;decpoint);  /* try updated decimal separator */</span>
<span class="lineNum">     185 </span><span class="lineCov">          1 :   if (!luaO_str2d(luaZ_buffer(ls-&gt;buff), &amp;seminfo-&gt;r)) {</span>
<span class="lineNum">     186 </span>            :     /* format error with correct decimal point: no more options */
<span class="lineNum">     187 </span><span class="lineCov">          1 :     buffreplace(ls, ls-&gt;decpoint, '.');  /* undo change (for error message) */</span>
<span class="lineNum">     188 </span><span class="lineCov">          1 :     luaX_lexerror(ls, &quot;malformed number&quot;, TK_NUMBER);</span>
<span class="lineNum">     189 </span>            :   }
<span class="lineNum">     190 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     191 </span>            : 
<span class="lineNum">     192 </span>            : 
<span class="lineNum">     193 </span>            : /* LUA_NUMBER */
<span class="lineNum">     194 </span><span class="lineCov">       4044 : static void read_numeral (LexState *ls, SemInfo *seminfo) {</span>
<span class="lineNum">     195 </span>            :   lua_assert(isdigit(ls-&gt;current));
<span class="lineNum">     196 </span>            :   do {
<span class="lineNum">     197 </span><span class="lineCov">       4044 :     save_and_next(ls);</span>
<span class="lineNum">     198 </span><span class="lineCov">       4044 :   } while (isdigit(ls-&gt;current) || ls-&gt;current == '.');</span>
<span class="lineNum">     199 </span><span class="lineCov">       3078 :   if (check_next(ls, &quot;Ee&quot;))  /* `E'? */</span>
<span class="lineNum">     200 </span><span class="lineCov">          7 :     check_next(ls, &quot;+-&quot;);  /* optional exponent sign */</span>
<span class="lineNum">     201 </span><span class="lineCov">       3461 :   while (isalnum(ls-&gt;current) || ls-&gt;current == '_')</span>
<span class="lineNum">     202 </span><span class="lineCov">        383 :     save_and_next(ls);</span>
<span class="lineNum">     203 </span><span class="lineCov">       3078 :   save(ls, '\0');</span>
<span class="lineNum">     204 </span><span class="lineCov">       3078 :   buffreplace(ls, '.', ls-&gt;decpoint);  /* follow locale for decimal point */</span>
<span class="lineNum">     205 </span><span class="lineCov">       3078 :   if (!luaO_str2d(luaZ_buffer(ls-&gt;buff), &amp;seminfo-&gt;r))  /* format error? */</span>
<span class="lineNum">     206 </span><span class="lineCov">          1 :     trydecpoint(ls, seminfo); /* try to update decimal point separator */</span>
<span class="lineNum">     207 </span><span class="lineCov">       3077 : }</span>
<span class="lineNum">     208 </span>            : 
<span class="lineNum">     209 </span>            : 
<span class="lineNum">     210 </span><span class="lineCov">       1733 : static int skip_sep (LexState *ls) {</span>
<span class="lineNum">     211 </span><span class="lineCov">       1733 :   int count = 0;</span>
<span class="lineNum">     212 </span><span class="lineCov">       1733 :   int s = ls-&gt;current;</span>
<span class="lineNum">     213 </span>            :   lua_assert(s == '[' || s == ']');
<span class="lineNum">     214 </span><span class="lineCov">       1733 :   save_and_next(ls);</span>
<span class="lineNum">     215 </span><span class="lineCov">       1747 :   while (ls-&gt;current == '=') {</span>
<span class="lineNum">     216 </span><span class="lineCov">         14 :     save_and_next(ls);</span>
<span class="lineNum">     217 </span><span class="lineCov">         14 :     count++;</span>
<span class="lineNum">     218 </span>            :   }
<span class="lineNum">     219 </span><span class="lineCov">       1733 :   return (ls-&gt;current == s) ? count : (-count) - 1;</span>
<span class="lineNum">     220 </span>            : }
<span class="lineNum">     221 </span>            : 
<span class="lineNum">     222 </span>            : 
<span class="lineNum">     223 </span><span class="lineCov">        532 : static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {</span>
<span class="lineNum">     224 </span><span class="lineCov">        532 :   int cont = 0;</span>
<span class="lineNum">     225 </span>            :   (void)(cont);  /* avoid warnings when `cont' is not used */
<span class="lineNum">     226 </span><span class="lineCov">        532 :   save_and_next(ls);  /* skip 2nd `[' */</span>
<span class="lineNum">     227 </span><span class="lineCov">        532 :   if (currIsNewline(ls))  /* string starts with a newline? */</span>
<span class="lineNum">     228 </span><span class="lineCov">        219 :     inclinenumber(ls);  /* skip it */</span>
<span class="lineNum">     229 </span>            :   for (;;) {
<span class="lineNum">     230 </span><span class="lineCov">      37585 :     switch (ls-&gt;current) {</span>
<span class="lineNum">     231 </span><span class="lineCov">          2 :       case EOZ:</span>
<span class="lineNum">     232 </span><span class="lineCov">          2 :         luaX_lexerror(ls, (seminfo) ? &quot;unfinished long string&quot; :</span>
<span class="lineNum">     233 </span>            :                                    &quot;unfinished long comment&quot;, TK_EOS);
<span class="lineNum">     234 </span><span class="lineNoCov">          0 :         break;  /* to avoid warnings */</span>
<span class="lineNum">     235 </span>            : #if defined(LUA_COMPAT_LSTR)
<span class="lineNum">     236 </span><span class="lineCov">          8 :       case '[': {</span>
<span class="lineNum">     237 </span><span class="lineCov">          8 :         if (skip_sep(ls) == sep) {</span>
<span class="lineNum">     238 </span><span class="lineNoCov">          0 :           save_and_next(ls);  /* skip 2nd `[' */</span>
<span class="lineNum">     239 </span><span class="lineNoCov">          0 :           cont++;</span>
<span class="lineNum">     240 </span>            : #if LUA_COMPAT_LSTR == 1
<span class="lineNum">     241 </span><span class="lineNoCov">          0 :           if (sep == 0)</span>
<span class="lineNum">     242 </span><span class="lineNoCov">          0 :             luaX_lexerror(ls, &quot;nesting of [[...]] is deprecated&quot;, '[');</span>
<span class="lineNum">     243 </span>            : #endif
<span class="lineNum">     244 </span>            :         }
<span class="lineNum">     245 </span><span class="lineCov">          8 :         break;</span>
<span class="lineNum">     246 </span>            :       }
<span class="lineNum">     247 </span>            : #endif
<span class="lineNum">     248 </span><span class="lineCov">        537 :       case ']': {</span>
<span class="lineNum">     249 </span><span class="lineCov">        537 :         if (skip_sep(ls) == sep) {</span>
<span class="lineNum">     250 </span><span class="lineCov">        530 :           save_and_next(ls);  /* skip 2nd `]' */</span>
<span class="lineNum">     251 </span>            : #if defined(LUA_COMPAT_LSTR) &amp;&amp; LUA_COMPAT_LSTR == 2
<span class="lineNum">     252 </span>            :           cont--;
<span class="lineNum">     253 </span>            :           if (sep == 0 &amp;&amp; cont &gt;= 0) break;
<span class="lineNum">     254 </span>            : #endif
<span class="lineNum">     255 </span><span class="lineCov">        530 :           goto endloop;</span>
<span class="lineNum">     256 </span>            :         }
<span class="lineNum">     257 </span><span class="lineCov">          7 :         break;</span>
<span class="lineNum">     258 </span>            :       }
<span class="lineNum">     259 </span><span class="lineCov">       1662 :       case '\n':</span>
<span class="lineNum">     260 </span>            :       case '\r': {
<span class="lineNum">     261 </span><span class="lineCov">       1662 :         save(ls, '\n');</span>
<span class="lineNum">     262 </span><span class="lineCov">       1662 :         inclinenumber(ls);</span>
<span class="lineNum">     263 </span><span class="lineCov">       1662 :         if (!seminfo) luaZ_resetbuffer(ls-&gt;buff);  /* avoid wasting space */</span>
<span class="lineNum">     264 </span><span class="lineCov">       1662 :         break;</span>
<span class="lineNum">     265 </span>            :       }
<span class="lineNum">     266 </span><span class="lineCov">      35376 :       default: {</span>
<span class="lineNum">     267 </span><span class="lineCov">      35376 :         if (seminfo) save_and_next(ls);</span>
<span class="lineNum">     268 </span><span class="lineCov">      29777 :         else next(ls);</span>
<span class="lineNum">     269 </span>            :       }
<span class="lineNum">     270 </span>            :     }
<span class="lineNum">     271 </span><span class="lineCov">        530 :   } endloop:</span>
<span class="lineNum">     272 </span><span class="lineCov">        530 :   if (seminfo)</span>
<span class="lineNum">     273 </span><span class="lineCov">        145 :     seminfo-&gt;ts = luaX_newstring(ls, luaZ_buffer(ls-&gt;buff) + (2 + sep),</span>
<span class="lineNum">     274 </span><span class="lineCov">        145 :                                      luaZ_bufflen(ls-&gt;buff) - 2*(2 + sep));</span>
<span class="lineNum">     275 </span><span class="lineCov">        530 : }</span>
<span class="lineNum">     276 </span>            : 
<span class="lineNum">     277 </span>            : 
<span class="lineNum">     278 </span><span class="lineCov">       6413 : static void read_string (LexState *ls, int del, SemInfo *seminfo) {</span>
<span class="lineNum">     279 </span><span class="lineCov">       6413 :   save_and_next(ls);</span>
<span class="lineNum">     280 </span><span class="lineCov">      74396 :   while (ls-&gt;current != del) {</span>
<span class="lineNum">     281 </span><span class="lineCov">      67988 :     switch (ls-&gt;current) {</span>
<span class="lineNum">     282 </span><span class="lineCov">          3 :       case EOZ:</span>
<span class="lineNum">     283 </span><span class="lineCov">          3 :         luaX_lexerror(ls, &quot;unfinished string&quot;, TK_EOS);</span>
<span class="lineNum">     284 </span><span class="lineNoCov">          0 :         continue;  /* to avoid warnings */</span>
<span class="lineNum">     285 </span><span class="lineCov">          1 :       case '\n':</span>
<span class="lineNum">     286 </span>            :       case '\r':
<span class="lineNum">     287 </span><span class="lineCov">          1 :         luaX_lexerror(ls, &quot;unfinished string&quot;, TK_STRING);</span>
<span class="lineNum">     288 </span><span class="lineNoCov">          0 :         continue;  /* to avoid warnings */</span>
<span class="lineNum">     289 </span><span class="lineCov">        419 :       case '\\': {</span>
<span class="lineNum">     290 </span>            :         int c;
<span class="lineNum">     291 </span><span class="lineCov">        419 :         next(ls);  /* do not save the `\' */</span>
<span class="lineNum">     292 </span><span class="lineCov">        419 :         switch (ls-&gt;current) {</span>
<span class="lineNum">     293 </span><span class="lineCov">          2 :           case 'a': c = '\a'; break;</span>
<span class="lineNum">     294 </span><span class="lineCov">          8 :           case 'b': c = '\b'; break;</span>
<span class="lineNum">     295 </span><span class="lineCov">         12 :           case 'f': c = '\f'; break;</span>
<span class="lineNum">     296 </span><span class="lineCov">         57 :           case 'n': c = '\n'; break;</span>
<span class="lineNum">     297 </span><span class="lineCov">         17 :           case 'r': c = '\r'; break;</span>
<span class="lineNum">     298 </span><span class="lineCov">        182 :           case 't': c = '\t'; break;</span>
<span class="lineNum">     299 </span><span class="lineCov">          2 :           case 'v': c = '\v'; break;</span>
<span class="lineNum">     300 </span><span class="lineCov">          1 :           case '\n':  /* go through */</span>
<span class="lineNum">     301 </span><span class="lineCov">          1 :           case '\r': save(ls, '\n'); inclinenumber(ls); continue;</span>
<span class="lineNum">     302 </span><span class="lineCov">          1 :           case EOZ: continue;  /* will raise an error next loop */</span>
<span class="lineNum">     303 </span><span class="lineCov">        137 :           default: {</span>
<span class="lineNum">     304 </span><span class="lineCov">        137 :             if (!isdigit(ls-&gt;current))</span>
<span class="lineNum">     305 </span><span class="lineCov">         74 :               save_and_next(ls);  /* handles \\, \&quot;, \', and \? */</span>
<span class="lineNum">     306 </span>            :             else {  /* \xxx */
<span class="lineNum">     307 </span><span class="lineCov">         63 :               int i = 0;</span>
<span class="lineNum">     308 </span><span class="lineCov">         63 :               c = 0;</span>
<span class="lineNum">     309 </span>            :               do {
<span class="lineNum">     310 </span><span class="lineCov">        105 :                 c = 10*c + (ls-&gt;current-'0');</span>
<span class="lineNum">     311 </span><span class="lineCov">        105 :                 next(ls);</span>
<span class="lineNum">     312 </span><span class="lineCov">        105 :               } while (++i&lt;3 &amp;&amp; isdigit(ls-&gt;current));</span>
<span class="lineNum">     313 </span><span class="lineCov">         63 :               if (c &gt; UCHAR_MAX)</span>
<span class="lineNum">     314 </span><span class="lineCov">          1 :                 luaX_lexerror(ls, &quot;escape sequence too large&quot;, TK_STRING);</span>
<span class="lineNum">     315 </span><span class="lineCov">         62 :               save(ls, c);</span>
<span class="lineNum">     316 </span>            :             }
<span class="lineNum">     317 </span><span class="lineCov">        136 :             continue;</span>
<span class="lineNum">     318 </span>            :           }
<span class="lineNum">     319 </span>            :         }
<span class="lineNum">     320 </span><span class="lineCov">        280 :         save(ls, c);</span>
<span class="lineNum">     321 </span><span class="lineCov">        280 :         next(ls);</span>
<span class="lineNum">     322 </span><span class="lineCov">        280 :         continue;</span>
<span class="lineNum">     323 </span>            :       }
<span class="lineNum">     324 </span><span class="lineCov">      67565 :       default:</span>
<span class="lineNum">     325 </span><span class="lineCov">      67565 :         save_and_next(ls);</span>
<span class="lineNum">     326 </span>            :     }
<span class="lineNum">     327 </span>            :   }
<span class="lineNum">     328 </span><span class="lineCov">       6408 :   save_and_next(ls);  /* skip delimiter */</span>
<span class="lineNum">     329 </span><span class="lineCov">      12816 :   seminfo-&gt;ts = luaX_newstring(ls, luaZ_buffer(ls-&gt;buff) + 1,</span>
<span class="lineNum">     330 </span><span class="lineCov">       6408 :                                    luaZ_bufflen(ls-&gt;buff) - 2);</span>
<span class="lineNum">     331 </span><span class="lineCov">       6408 : }</span>
<span class="lineNum">     332 </span>            : 
<span class="lineNum">     333 </span>            : 
<span class="lineNum">     334 </span><span class="lineCov">      87635 : static int llex (LexState *ls, SemInfo *seminfo) {</span>
<span class="lineNum">     335 </span><span class="lineCov">      87635 :   luaZ_resetbuffer(ls-&gt;buff);</span>
<span class="lineNum">     336 </span>            :   for (;;) {
<span class="lineNum">     337 </span><span class="lineCov">     235910 :     switch (ls-&gt;current) {</span>
<span class="lineNum">     338 </span><span class="lineCov">      20410 :       case '\n':</span>
<span class="lineNum">     339 </span>            :       case '\r': {
<span class="lineNum">     340 </span><span class="lineCov">      20410 :         inclinenumber(ls);</span>
<span class="lineNum">     341 </span><span class="lineCov">      20410 :         continue;</span>
<span class="lineNum">     342 </span>            :       }
<span class="lineNum">     343 </span><span class="lineCov">       2679 :       case '-': {</span>
<span class="lineNum">     344 </span><span class="lineCov">       2679 :         next(ls);</span>
<span class="lineNum">     345 </span><span class="lineCov">       2679 :         if (ls-&gt;current != '-') return '-';</span>
<span class="lineNum">     346 </span>            :         /* else is a comment */
<span class="lineNum">     347 </span><span class="lineCov">       2391 :         next(ls);</span>
<span class="lineNum">     348 </span><span class="lineCov">       2391 :         if (ls-&gt;current == '[') {</span>
<span class="lineNum">     349 </span><span class="lineCov">        386 :           int sep = skip_sep(ls);</span>
<span class="lineNum">     350 </span><span class="lineCov">        386 :           luaZ_resetbuffer(ls-&gt;buff);  /* `skip_sep' may dirty the buffer */</span>
<span class="lineNum">     351 </span><span class="lineCov">        386 :           if (sep &gt;= 0) {</span>
<span class="lineNum">     352 </span><span class="lineCov">        386 :             read_long_string(ls, NULL, sep);  /* long comment */</span>
<span class="lineNum">     353 </span><span class="lineCov">        385 :             luaZ_resetbuffer(ls-&gt;buff);</span>
<span class="lineNum">     354 </span><span class="lineCov">        385 :             continue;</span>
<span class="lineNum">     355 </span>            :           }
<span class="lineNum">     356 </span>            :         }
<span class="lineNum">     357 </span>            :         /* else short comment */
<span class="lineNum">     358 </span><span class="lineCov">      38739 :         while (!currIsNewline(ls) &amp;&amp; ls-&gt;current != EOZ)</span>
<span class="lineNum">     359 </span><span class="lineCov">      36734 :           next(ls);</span>
<span class="lineNum">     360 </span><span class="lineCov">       2005 :         continue;</span>
<span class="lineNum">     361 </span>            :       }
<span class="lineNum">     362 </span><span class="lineCov">        802 :       case '[': {</span>
<span class="lineNum">     363 </span><span class="lineCov">        802 :         int sep = skip_sep(ls);</span>
<span class="lineNum">     364 </span><span class="lineCov">        802 :         if (sep &gt;= 0) {</span>
<span class="lineNum">     365 </span><span class="lineCov">        146 :           read_long_string(ls, seminfo, sep);</span>
<span class="lineNum">     366 </span><span class="lineCov">        145 :           return TK_STRING;</span>
<span class="lineNum">     367 </span>            :         }
<span class="lineNum">     368 </span><span class="lineCov">        656 :         else if (sep == -1) return '[';</span>
<span class="lineNum">     369 </span><span class="lineCov">          1 :         else luaX_lexerror(ls, &quot;invalid long string delimiter&quot;, TK_STRING);</span>
<span class="lineNum">     370 </span>            :       }
<span class="lineNum">     371 </span><span class="lineCov">       4219 :       case '=': {</span>
<span class="lineNum">     372 </span><span class="lineCov">       4219 :         next(ls);</span>
<span class="lineNum">     373 </span><span class="lineCov">       4219 :         if (ls-&gt;current != '=') return '=';</span>
<span class="lineNum">     374 </span><span class="lineCov">        388 :         else { next(ls); return TK_EQ; }</span>
<span class="lineNum">     375 </span>            :       }
<span class="lineNum">     376 </span><span class="lineCov">         83 :       case '&lt;': {</span>
<span class="lineNum">     377 </span><span class="lineCov">         83 :         next(ls);</span>
<span class="lineNum">     378 </span><span class="lineCov">         83 :         if (ls-&gt;current != '=') return '&lt;';</span>
<span class="lineNum">     379 </span><span class="lineCov">         39 :         else { next(ls); return TK_LE; }</span>
<span class="lineNum">     380 </span>            :       }
<span class="lineNum">     381 </span><span class="lineCov">        173 :       case '&gt;': {</span>
<span class="lineNum">     382 </span><span class="lineCov">        173 :         next(ls);</span>
<span class="lineNum">     383 </span><span class="lineCov">        173 :         if (ls-&gt;current != '=') return '&gt;';</span>
<span class="lineNum">     384 </span><span class="lineCov">        137 :         else { next(ls); return TK_GE; }</span>
<span class="lineNum">     385 </span>            :       }
<span class="lineNum">     386 </span><span class="lineCov">        237 :       case '~': {</span>
<span class="lineNum">     387 </span><span class="lineCov">        237 :         next(ls);</span>
<span class="lineNum">     388 </span><span class="lineCov">        237 :         if (ls-&gt;current != '=') return '~';</span>
<span class="lineNum">     389 </span><span class="lineCov">        237 :         else { next(ls); return TK_NE; }</span>
<span class="lineNum">     390 </span>            :       }
<span class="lineNum">     391 </span><span class="lineCov">       6413 :       case '&quot;':</span>
<span class="lineNum">     392 </span>            :       case '\'': {
<span class="lineNum">     393 </span><span class="lineCov">       6413 :         read_string(ls, ls-&gt;current, seminfo);</span>
<span class="lineNum">     394 </span><span class="lineCov">       6408 :         return TK_STRING;</span>
<span class="lineNum">     395 </span>            :       }
<span class="lineNum">     396 </span><span class="lineCov">       3858 :       case '.': {</span>
<span class="lineNum">     397 </span><span class="lineCov">       3858 :         save_and_next(ls);</span>
<span class="lineNum">     398 </span><span class="lineCov">       3858 :         if (check_next(ls, &quot;.&quot;)) {</span>
<span class="lineNum">     399 </span><span class="lineCov">       1864 :           if (check_next(ls, &quot;.&quot;))</span>
<span class="lineNum">     400 </span><span class="lineCov">         37 :             return TK_DOTS;   /* ... */</span>
<span class="lineNum">     401 </span><span class="lineCov">       1827 :           else return TK_CONCAT;   /* .. */</span>
<span class="lineNum">     402 </span>            :         }
<span class="lineNum">     403 </span><span class="lineCov">       1994 :         else if (!isdigit(ls-&gt;current)) return '.';</span>
<span class="lineNum">     404 </span>            :         else {
<span class="lineNum">     405 </span><span class="lineCov">          1 :           read_numeral(ls, seminfo);</span>
<span class="lineNum">     406 </span><span class="lineCov">          1 :           return TK_NUMBER;</span>
<span class="lineNum">     407 </span>            :         }
<span class="lineNum">     408 </span>            :       }
<span class="lineNum">     409 </span><span class="lineCov">        450 :       case EOZ: {</span>
<span class="lineNum">     410 </span><span class="lineCov">        450 :         return TK_EOS;</span>
<span class="lineNum">     411 </span>            :       }
<span class="lineNum">     412 </span><span class="lineCov">     196586 :       default: {</span>
<span class="lineNum">     413 </span><span class="lineCov">     196586 :         if (isspace(ls-&gt;current)) {</span>
<span class="lineNum">     414 </span>            :           lua_assert(!currIsNewline(ls));
<span class="lineNum">     415 </span><span class="lineCov">     125475 :           next(ls);</span>
<span class="lineNum">     416 </span><span class="lineCov">     125475 :           continue;</span>
<span class="lineNum">     417 </span>            :         }
<span class="lineNum">     418 </span><span class="lineCov">      71111 :         else if (isdigit(ls-&gt;current)) {</span>
<span class="lineNum">     419 </span><span class="lineCov">       3077 :           read_numeral(ls, seminfo);</span>
<span class="lineNum">     420 </span><span class="lineCov">       3076 :           return TK_NUMBER;</span>
<span class="lineNum">     421 </span>            :         }
<span class="lineNum">     422 </span><span class="lineCov">      68034 :         else if (isalpha(ls-&gt;current) || ls-&gt;current == '_') {</span>
<span class="lineNum">     423 </span>            :           /* identifier or reserved word */
<span class="lineNum">     424 </span>            :           TString *ts;
<span class="lineNum">     425 </span>            :           do {
<span class="lineNum">     426 </span><span class="lineCov">     167932 :             save_and_next(ls);</span>
<span class="lineNum">     427 </span><span class="lineCov">     167932 :           } while (isalnum(ls-&gt;current) || ls-&gt;current == '_');</span>
<span class="lineNum">     428 </span><span class="lineCov">      39368 :           ts = luaX_newstring(ls, luaZ_buffer(ls-&gt;buff),</span>
<span class="lineNum">     429 </span><span class="lineCov">      39368 :                                   luaZ_bufflen(ls-&gt;buff));</span>
<span class="lineNum">     430 </span><span class="lineCov">      39368 :           if (ts-&gt;tsv.reserved &gt; 0)  /* reserved word? */</span>
<span class="lineNum">     431 </span><span class="lineCov">      13272 :             return ts-&gt;tsv.reserved - 1 + FIRST_RESERVED;</span>
<span class="lineNum">     432 </span>            :           else {
<span class="lineNum">     433 </span><span class="lineCov">      26096 :             seminfo-&gt;ts = ts;</span>
<span class="lineNum">     434 </span><span class="lineCov">      26096 :             return TK_NAME;</span>
<span class="lineNum">     435 </span>            :           }
<span class="lineNum">     436 </span>            :         }
<span class="lineNum">     437 </span>            :         else {
<span class="lineNum">     438 </span><span class="lineCov">      28666 :           int c = ls-&gt;current;</span>
<span class="lineNum">     439 </span><span class="lineCov">      28666 :           next(ls);</span>
<span class="lineNum">     440 </span><span class="lineCov">      28666 :           return c;  /* single-char tokens (+ - / ...) */</span>
<span class="lineNum">     441 </span>            :         }
<span class="lineNum">     442 </span>            :       }
<span class="lineNum">     443 </span>            :     }
<span class="lineNum">     444 </span>            :   }
<span class="lineNum">     445 </span>            : }
<span class="lineNum">     446 </span>            : 
<span class="lineNum">     447 </span>            : 
<span class="lineNum">     448 </span><span class="lineCov">      87635 : void luaX_next (LexState *ls) {</span>
<span class="lineNum">     449 </span><span class="lineCov">      87635 :   ls-&gt;lastline = ls-&gt;linenumber;</span>
<span class="lineNum">     450 </span><span class="lineCov">      87635 :   if (ls-&gt;lookahead.token != TK_EOS) {  /* is there a look-ahead token? */</span>
<span class="lineNum">     451 </span><span class="lineCov">        543 :     ls-&gt;t = ls-&gt;lookahead;  /* use this one */</span>
<span class="lineNum">     452 </span><span class="lineCov">        543 :     ls-&gt;lookahead.token = TK_EOS;  /* and discharge it */</span>
<span class="lineNum">     453 </span>            :   }
<span class="lineNum">     454 </span>            :   else
<span class="lineNum">     455 </span><span class="lineCov">      87092 :     ls-&gt;t.token = llex(ls, &amp;ls-&gt;t.seminfo);  /* read next token */</span>
<span class="lineNum">     456 </span><span class="lineCov">      87626 : }</span>
<span class="lineNum">     457 </span>            : 
<span class="lineNum">     458 </span>            : 
<span class="lineNum">     459 </span><span class="lineCov">        543 : void luaX_lookahead (LexState *ls) {</span>
<span class="lineNum">     460 </span>            :   lua_assert(ls-&gt;lookahead.token == TK_EOS);
<span class="lineNum">     461 </span><span class="lineCov">        543 :   ls-&gt;lookahead.token = llex(ls, &amp;ls-&gt;lookahead.seminfo);</span>
<span class="lineNum">     462 </span><span class="lineCov">        543 : }</span>
<span class="lineNum">     463 </span>            : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.13</a></td></tr>
  </table>
  <br>

</body>
</html>
